import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public final class u {

    private static Image d;
    public Image a;
    public Image b[];
    public int c[];
    private short e;
    private short f;

    private static u b(byte abyte0[]) {
        if (abyte0 == null || abyte0.length < 4)
            return new u(e());
        int ai[];
        Image aimage[];
        try {
            if (abyte0[0] == 65 && abyte0[1] == 73) {
                DataInputStream datainputstream;
                (datainputstream = new DataInputStream(new ByteArrayInputStream(abyte0))).readShort();
                int i = datainputstream.readInt();
                ai = new int[2 + 6 * i];
                for (int j = 0; j < ai.length; j++)
                    ai[j] = datainputstream.readInt();

                int k = 6 + ai.length * 4;
                aimage = new Image[i];
                for (int l = 0; l < aimage.length; l++) {
                    int i1 = datainputstream.readInt();
                    k += 4;
                    aimage[l] = Image.createImage(abyte0, k, i1);
                    datainputstream.skip(i1);
                    k += i1;
                }

                return new u(aimage, ai);
            } else {
                return new u(Image.createImage(abyte0, 0, abyte0.length));
            }
        } catch (Exception ex) {
            return new u(e());
        }
    }

    public static u a() {
        return a(e());
    }

    private static Image e() {
        if (d == null) {
            Image image;
            Graphics g;
            (g = (image = Image.createImage(20, 20)).getGraphics()).setColor(0xffffff);
            g.fillRect(0, 0, 10, 10);
            g.fillRect(10, 10, 10, 10);
            g.setColor(0xd93939);
            g.fillRect(10, 0, 10, 10);
            g.fillRect(0, 10, 10, 10);
            d = image;
        }
        return d;
    }

    public static u a(String s) {
        try {
            return new u(Image.createImage(s));
        } catch (IOException e1) {
            return a();
        }
    }

    public static u a(bw bw1) {
        return b(bw1.a());
    }

    public static u a(bl bl1, String s) {
        return b(bl1.c(s));
    }

    public static u a(byte abyte0[]) {
        return b(abyte0);
    }

    public static u a(Image image) {
        return new u(image);
    }

    public static u a(u u1, int i, int j, int k, int l) {
        return new u(Image.createImage(u1.a, i, j, k, l, 0));
    }

    private u(Image image) {
        a = image;
    }

    private u(Image aimage[], int ai[]) {
        a = aimage[0];
        b = aimage;
        c = ai;
        e = (short) c[0];
        f = (short) c[1];
    }

    public final int b() {
        if (e == 0)
            e = (short) a.getWidth();
        return e;
    }

    public final int c() {
        if (f == 0)
            f = (short) a.getHeight();
        return f;
    }

    public final boolean d() {
        return b != null;
    }
}